package com.chujian.framework.sync;

import cn.hutool.core.collection.CollUtil;

import java.util.Set;

public interface SyncConst {

    String SYNC_AOP_ADVISER_BEAN = "syncDataAdvisor";

    // BaseService 定义的方法
    String METHOD_INS = "ins";
    String METHOD_UPD = "upd";
    String METHOD_DEL = "del";
    String METHOD_DELS = "dels";

    // mybatis.IService 定义的方法
    String METHOD_SAVE = "save";
    String METHOD_SAVE_BATCH = "saveBatch";
    String METHOD_SAVE_OR_UPDATE = "saveOrUpdate";
    String METHOD_SAVE_OR_UPDATE_BATCH = "saveOrUpdateBatch";
    String METHOD_REMOVE_BY_ID = "removeById";
    String METHOD_REMOVE_BY_MAP = "removeByMap";
    String METHOD_REMOVE = "remove";
    String METHOD_REMOVE_BY_IDS = "removeByIds";
    String METHOD_UPDATE_BY_ID = "updateById";
    String METHOD_UPDATE = "update";
    String METHOD_UPDATE_BATCH_BY_ID = "updateBatchById";

    Set<String> NEED_SYNC_METHODS = CollUtil.newHashSet(
            METHOD_INS,
            METHOD_UPD,
            METHOD_DEL,
            METHOD_DELS,

            METHOD_SAVE,
            METHOD_SAVE_BATCH,
            METHOD_SAVE_OR_UPDATE_BATCH,
            METHOD_SAVE_OR_UPDATE,
            METHOD_REMOVE_BY_ID,
            METHOD_REMOVE_BY_MAP,
            METHOD_REMOVE,
            METHOD_REMOVE_BY_IDS,
            METHOD_UPDATE_BY_ID,
            METHOD_UPDATE,
            METHOD_UPDATE_BATCH_BY_ID
    );

    // 数据变更类型
    String CHANGE_TYPE_INSERT = "insert";
    String CHANGE_TYPE_UPDATE = "update";
    String CHANGE_TYPE_DELETE = "delete";

    // 同步请求头
    String HEADER_DATA_MARK = "sync-datatype";
    String HEADER_DATA_ID = "sync-dataId";
    String HEADER_CHANGE_TYPE = "sync-changeType";

}
